A set is a collection of data items of the same ordinal type
(called the base type). The SET type definition specifies the
values that can be elements of a variable of that type.
Syntax:
[[PACKED]] SET OF [[attribute-list]] base-type
The 'attribute-list' is one or more optional identifiers that
provide additional information about the base type.
The 'base-type' is the ordinal type identifier or type
definition, or discriminated schema type, from which the set
elements are selected. Note that real numbers cannot be
elements of a set type.
Example: SET OF CHAR
Some possible set constructors for this set type are:
['A, 'E', 'I', 'O', 'U']
['B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z']
1 – Set constructor
Set constructors are lists of values that you can use to
initialize a set. The syntax for set constructors is as
follows:
[[data-type]] [ [[{component-value},...]] ]
The 'data-type' is the data type of the constructor. This
identifier is optional when used in the CONST and executable
sections; do not use this identifier in the TYPE and VAR
sections or in nested constructors.
The 'component-value' specifies values within the range of the
defined data type. Component values can be subranges (..) to
indicate consecutive values that appear in the set definition.
These values are compile-time values; if you use the constructor
in the executable section, you can also use run-time values.
A set having no elements is called an empty set and is written
as empty brackets ([]).
A possible constructor for a variable of type SET OF 35..115 is
the following:
VAR
Numbers : SET OF 35..115 VALUE [39, 67, 110..115];
{In the executable section, run-time expressions are legal:}
Numbers := [39, 67, x+95, 110..115]
The set constructors contain up to nine values: 39, 67, 95 or
x+95, and integers between 110 and 115, inclusive. If the
expression x+95 evaluates to an integer outside the range
35..115, then VSI Pascal includes no set element for that
expression.